<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>



<link href="style/cs1.css" rel="stylesheet" type="text/css" />
</head>

<body>
<?php
$gia_tu = $_GET["gia_tu"];
$gia_den = $_GET["gia_den"];
include("config/config.php");
$lenh = "select malaptop, tenlaptop, hinh, concat(soluong, ' Cái')as soluong, concat(format(dongia,0),' VNĐ') as dongia from laptop,hanglaptop where laptop.mahanglaptop=hanglaptop.mahanglaptop and dongia >= '$gia_tu' and dongia <= '$gia_den' ";

$kq = mysql_query($lenh);
$n = mysql_num_rows($kq);
if($n > 0)
{
	$tb = "Tìm thấy ".$n. " laptop";	
}
else
{
	$tb = "Không tìm thấy laptop nào";
}
$sodong = 5;
$sotrang = ceil($n/$sodong);
if(!$_GET["p"])
$p = 1;
else
$p = $_GET["p"];
$x = ($p - 1)*$sodong;
$lenh1 = "select malaptop, tenlaptop, hinh, concat(soluong, ' Cái')as soluong, concat(format(dongia,0),' VNĐ') as dongia from laptop,hanglaptop where laptop.mahanglaptop=hanglaptop.mahanglaptop and dongia >= '$gia_tu' and dongia <= '$gia_den' limit $x,$sodong";

$kq1 = mysql_query($lenh1);
?>
<form id="form1" name="form1" method="get" action="" >
  <table width="900" border="1" align="center" cellpadding="0" cellspacing="0" class="table_timkemtheogia" onsubmit="return  validForm_search_1()" enctype="multipart/form-data">
    <tr>
      <td height="30" colspan="2" align="center"><strong>TÌM KIẾM SẢN PHẨM THEO GIÁ</strong></td>
    </tr>
    <tr>
      <td width="241" height="30" align="center"><em><strong>Giá từ</strong></em></td>
      <td width="553" height="30"><label for="gia_tu"></label>
	  <input name="act" type="hidden" value="laptoptheogia">
        <select name="gia_tu" class="listtimtheogia" id="gia_tu">
        <option value="">-- Giá từ --</option>
        <?php 
		for($i = 1000000;$i<=200000000;$i+= 500000)
		{
			?>
            <option value="<?php echo $i; ?>"<?php if($_GET["gia_tu"]==$i){?> selected <?php }?>> <?php echo number_format($i,0,',','.'); ?> </option>
            <?php
			
		}
		?>
      </select>
      <input name="button" type="submit" class="nuttimkiem" id="button" value="Tìm Kiếm" /></td>
    </tr>
    <tr>
      <td height="30" align="center"><strong><em>Giá đến</em></strong></td>
      <td height="30"><label for="gia_den"></label>
        <select name="gia_den" class="listtimtheogia" id="gia_den">
          <option value="">-- Giá đến --</option>
          <?php 
		for($i = 1000000;$i<=200000000;$i+= 500000)
		{
			?>
          <option value="<?php echo $i; ?>"<?php if($_GET["gia_den"]==$i){?> selected="selected" <?php }?>> <?php echo number_format($i,0,',','.'); ?></option>
          <?php
			
		}
		?>
      </select></td>
    </tr>
    <tr>
      <td height="30" colspan="2" align="center"><?php if(isset($_REQUEST["gia_tu"])) echo $tb; ?></td>
    </tr>
    <?php
	if(isset($_REQUEST["gia_tu"]))
	{
		while ($row = mysql_fetch_array($kq1))
	  {
		$tt = str_replace($gia_tu,'<span style="background-color:#FFFF33; color:#FF0000">'.$gia_tu.'</span>',$row[1]);
	  ?>
    <tr>
      <td height="30" align="center">
      <img src="laptop/<?php echo $row[2] ?>" width="100" height="80"><br/>
      </td>
      <td height="30">
        <p class="padding_timkiemtheogia"><font color="#0000FF"><strong>Tên laptop:</strong></font><?php echo $tt ?></p>
        <p class="padding_timkiemtheogia"><font color="#0000FF"><strong>Đơn giá:</strong></font><?php echo $row[4]  ?><br/>
        <!--<p class="padding_timkiemtheogia"><font color="#0000FF"><strong>Số lượng:</strong></font><?php echo $row[3]  ?><br/>-->
        <div class="xemchitiet"><a href="index.php?idlaptop=<?php echo $row[0];   ?>">Xem chi tiêt >></a><br/>
           <a href="index.php?act=gh&Malaptop=<?php  echo $row[6];?>"><img src="image/dathang.gif" width="103" height="30" border="0" /></a>
           </div>
      </p></td>
    </tr>
    <?php
	  }
	}
	?>
  </table>
</form>
  <p align="center" style="clear:both">
  <?php
  if(isset($_REQUEST["gia_tu"]))
  {
  for($i = 1; $i <= $sotrang; $i++)
  {
	  if($p == $i)
	  {
		  echo "&nbsp;".$i."&nbsp;";
	  }
	  else
	  {
	?>
          <a href ="index.php?act=laptoptheogia&gia_tu=<?php echo $gia_tu; ?>&gia_den=<?php echo $gia_den; ?>&p=<?php echo $i; ?>"> <?php echo $i; ?></a>
   <?php
	  }
  }
  }
  ?>

</body>
</html>